//
//  JCollectShopCell.m
//  HeadIndustry
//
//  Created by jun on 2017/9/13.
//  Copyright © 2017年 jun. All rights reserved.
//

#import "JCollectShopCell.h"

@interface JCollectShopCell()

@property (nonatomic, strong) CALayer *headImg;
@property (nonatomic, strong) YYLabel *name;
@property (nonatomic, strong) UILabel *saleCount;
@property (nonatomic, strong) UILabel *collectCount;

@end

@implementation JCollectShopCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.opaque = NO;
        self.backgroundColor = [UIColor whiteColor];
        [self setConfigBgView];
    }
    return self;
}

- (void)setConfigBgView {
    CALayer *imgLayer = [CALayer layer];
    imgLayer.frame = CGRectMake(15, 10, 60, 60);
    imgLayer.cornerRadius = 30;
    [self.contentView.layer addSublayer:imgLayer];
    _headImg = imgLayer;
    
    YYLabel *nameL = [YYLabel new];
    nameL.frame = CGRectMake(imgLayer.right + 10, 0, kWindowW - imgLayer.right - 10 - 15, 40);
    nameL.font = kFONT_TITLE(16);
    [self.contentView addSubview:nameL];
    _name = nameL;
    
    UILabel *saleL = [[UILabel alloc]initWithFrame:CGRectMake(imgLayer.right + 10, nameL.bottom, 80, 40)];
    saleL.font = kFONT_TITLE(14);
    saleL.textColor = kRGBColor(150, 150, 150);
    [self.contentView addSubview:saleL];
    _saleCount = saleL;
    
    UILabel *collectL = [UILabel new];
    collectL.frame = CGRectMake(saleL.right + 10, nameL.bottom, kWindowW - saleL.right - 10 - 15, 40);
    collectL.font = kFONT_TITLE(14);
    collectL.textColor = kRGBColor(150, 150, 150);
    [self.contentView addSubview:collectL];
    _collectCount = collectL;
    
    CALayer *line = [CALayer layer];
    line.backgroundColor = kRGBColor(150, 150, 150).CGColor;
    line.frame = CGRectMake(0, 80 - 0.5 , kWindowW, 0.5);
    [self.contentView.layer addSublayer:line];
    
}

- (void)setVerdorModel:(JVendorModel *)verdorModel
{
    _verdorModel = verdorModel;
    if (verdorModel.LogoImgUrl.length > 0) {
        UIImage *img = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:verdorModel.LogoImgUrl]]];
        _headImg.contents = (__bridge id _Nullable)(img.CGImage);
    }
    _name.text = verdorModel.Name;
    _saleCount.text = [NSString stringWithFormat:@"售量: %@",verdorModel.SaleCount];
    _collectCount.text = [NSString stringWithFormat:@"收藏: %@",verdorModel.CollectCount];
    
    [_saleCount sizeToFit];
    [_collectCount sizeToFit];
    
    _saleCount.frame = CGRectMake(_saleCount.origin.x, _saleCount.origin.y, _saleCount.width, 40);
    _collectCount.frame = CGRectMake(_saleCount.right + 10, _saleCount.origin.y, _collectCount.width, 40);
    
    
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
